package org.lg.web.controller;

import org.lg.config.*;
import org.lg.dto.BaseDto;
import org.lg.dto.MessageEnum;
import org.lg.entity.Teacher;
import org.lg.page.PageInfo;
import org.lg.service.TeacherService;
import org.lg.service.impl.TeacherServiceImpl;

/**
 * 学生类的控制器 门卫 对url的响应处理
 */
@Controller("/teacherController")
public class TeacherController {
    @Resource
    TeacherService teacherService;
    /**
     * 查询全部学生 示例 无参数方法
     * @return
     */
    @RequestMapping("/getTeachers")
    @ResponseBody
    public BaseDto getAllTeachers() throws Exception {
        return  teacherService.getAllTeachers();
    }

    @RequestMapping("/getTeacherByPage")
    @ResponseBody
    public BaseDto getTeacherByPage(@RequestBody PageInfo pageInfo) throws Exception {
        return  teacherService.getTeacherByPage(pageInfo);
    }
    @RequestMapping("/getTop6Teacher")
    @ResponseBody
    public BaseDto getTop6Teacher( ) throws Exception {
        return  teacherService.getTop6Teacher();
    }




    /**
     * 根据主键查询 示范简单参数
     * @param id
     * @return
     */
    @RequestMapping("/getTeacherById/{id}")
    public BaseDto getTeacherById(String id) throws Exception{
        System.out.println(id);
        BaseDto dto = new BaseDto(MessageEnum.GETTEACHERBYIDSUCCESS);
        return  dto;
    }
    /*

     */
    @RequestMapping("/addTeacher")
    @ResponseBody
    public BaseDto addTeacher(Teacher Teacher) throws Exception{
        System.out.println(Teacher);
        BaseDto dto = new BaseDto(MessageEnum.ADDTEACHERSUCCESS,Teacher);
        return  dto;
    }

    @RequestMapping("/editTeacher")
    @ResponseBody
    public BaseDto editTeacher(@RequestBody Teacher Teacher){
        System.out.println(Teacher);
        BaseDto dto = new BaseDto(MessageEnum.ADDTEACHERSUCCESS,Teacher);
        return  dto;
    }
    @RequestMapping("/cancelCourse")
    public BaseDto cancelCourse(String courseJson){
        BaseDto dto = new BaseDto(MessageEnum.GETTEACHERBYIDSUCCESS);
        return  dto;
    }
}

